package com.wish.renting.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MsgUtil {

    //发件人
    private String from="937058265@qq.com";

    @Autowired
    private JavaMailSender sender;

    public void sendTextEmail(String to,String subject,String content){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);//发送人
        message.setTo(to);//收件人
        message.setSubject(subject);//主题
        message.setText(content);//内容
        message.setSentDate(new Date());//发送时间
        sender.send(message);//执行发送邮件
    }
}